﻿<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>jQuery子元素过滤器:only-child示例</title>
        <script src="js/jquery-1.12.4.js"></script>
        <style>
            ul{ width:150px; border:1px solid; float:left; margin:10px; }
        </style>
    </head>
    <body>
        <h3>jQuery子元素过滤器:only-child示例</h3>
        <hr>
        <ul>
            <li>苹果</li>
            <li>香蕉</li>
            <li>荔枝</li>
        </ul>
        <ul>
            <li>西瓜</li>
        </ul>
        <ul>
            该ul元素内部无子元素。
        </ul>
        <script>
            $(document).ready(function() {
                //选择唯一的子元素li
                $("ul li:only-child").css("color","red");
            });
        </script>
    </body>
</html>
